package dws_api

import (
	"server/apps/dws/dws_fld"
	"server/apps/dws/dws_tb"
	"server/global"
)


type DwsApi struct {
	TopicId   uint   `json:"topicId" form:"topicId" gorm:"column:topicId;comment:主题id;"`
	TopicName string `json:"topicName" form:"topicName" gorm:"column:topicName;comment:主题名称;"`
	TopicCode string `json:"topicCode" form:"topicCode" gorm:"column:topicCode;comment:主题编码;"`

	Name string `json:"name" form:"name" gorm:"column:name;comment:API名称;size:50;"`
	Code string `json:"code" form:"code" gorm:"column:code;comment:API编码;size:50;"`
	Type string `json:"type" form:"type" gorm:"column:type;comment:API类型;size:50;"`

	Request string `json:"request" form:"request" gorm:"column:request;comment:请求方式;size:50;"`
	Deny    string `json:"deny" form:"deny" gorm:"column:deny;comment:IP黑名单多个，隔开;size:2000;"`
	Status  *bool  `json:"status" form:"status" gorm:"column:status;comment:状态（0不启用，1启用）;"`
	Remark  string `json:"remark" form:"remark" gorm:"column:remark;comment:备注;size:1000;"`

	global.BaseModel
	CreatedBy uint `gorm:"column:created_by;comment:创建者"`
	UpdatedBy uint `gorm:"column:updated_by;comment:更新者"`
	DeletedBy uint `gorm:"column:deleted_by;comment:删除者"`
}


type ApiConfig struct {
	DwsApi  DwsApi           `json:"dwsApi"`
	DwsTbs  []dws_tb.DwsTb   `json:"dwsTbs"`
	DwsFlds []dws_fld.DwsFld `json:"dwsFlds"`
}


type ApiFilter struct {
	ColName   string `json:"colName"`
	Condition string `json:"condition"`
	ColValue  string `json:"colValue"`
}


type ApiRequest struct {
	Topic     string      `json:"topic"`
	Name      string      `json:"name"`
	OrderBy   string      `json:"orderBy"`
	Limit     string      `json:"limit"`
	ApiFilter []ApiFilter `json:"apiFilter"`
}


func (DwsApi) TableName() string {
	return "dws_api"
}
